| Conditions | 1 |
| Paths | 1 |
| Total Lines | 35 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 2 | ||
| Bugs | 0 | Features | 0 |
| 1 | /** global: jest */ |
||
| 5 | describe('Index routes.', () => { |
||
| 6 | const request = { |
||
| 7 | method: 'POST', |
||
| 8 | url: '/testId', |
||
| 9 | headers: {}, |
||
| 10 | connection: { |
||
| 11 | socket: { remoteAddress: 'testIp' }, |
||
| 12 | }, |
||
| 13 | socket: {}, |
||
| 14 | body: '', |
||
| 15 | }; |
||
| 16 | |||
| 17 | test('POST plain text into page with certain streamId', (done) => { |
||
| 18 | request.headers = { 'x-forwarded-for': 'testIp', 'content-type': 'text/plain' }; |
||
| 19 | request.body = 'Test with plain text body.'; |
||
| 20 | const response = { status: jest.fn(), send: () => done() }; |
||
| 21 | |||
| 22 | router.handle(request, response); |
||
| 23 | }); |
||
| 24 | |||
| 25 | test('POST JSON data into page with certain streamId', (done) => { |
||
| 26 | request.headers = { 'content-type': 'application/json' }; |
||
| 27 | request.body = '{"decs": "JSON data"}'; |
||
| 28 | const response = { status: jest.fn(), send: jest.fn() }; |
||
| 29 | global.socket = { |
||
| 30 | emit: (type, data) => { |
||
| 31 | expect(type).toBe('log'); |
||
| 32 | expect(typeof data).toBe('object'); |
||
| 33 | done(); |
||
| 34 | }, |
||
| 35 | }; |
||
| 36 | |||
| 37 | router.handle(request, response); |
||
| 38 | }); |
||
| 39 | }); |
||
| 40 |